home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxalpha.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.1 KB  |  69 lines

  1. /* Copyright (C) 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxalpha.h,v 1.2 2000/09/19 19:00:33 lpd Exp $ */
  20. /* Internal machinery for alpha channel support */
  21.  
  22. #ifndef gxalpha_INCLUDED
  23. #  define gxalpha_INCLUDED
  24.  
  25. /*
  26.  * As discussed in the classic Porter & Duff paper on compositing,
  27.  * supporting alpha channel properly involves premultiplying color values
  28.  * that are associated with non-unity alpha values.  After considerable
  29.  * thrashing around trying to read between the lines of the spotty NeXT
  30.  * documentation, we've concluded that the correct approach is to
  31.  * premultiply towards whatever the color value 0 represents in the device's
  32.  * native color space: black for DeviceGray and DeviceRGB (displays and some
  33.  * file formats), white for DeviceCMYK (color printers), with a special hack
  34.  * for monochrome printers TBD.  This makes things very easy internally, at
  35.  * the expense of some inconsistency at the boundaries.
  36.  *
  37.  * For the record, the only places apparently affected by this decision
  38.  * are the following:
  39.  *      - alphaimage, if it doesn't assume premultiplication (see below)
  40.  *      - readimage
  41.  *      - The cmap_rgb_alpha_ procedures in gxcmap.c
  42.  *      - [color]image, if they are supposed to use currentalpha (see below)
  43.  *      - The compositing code in gsalphac.c
  44.  *
  45.  * The NeXT documentation also is very unclear as to how readimage,
  46.  * alphaimage, and [color]image are supposed to work.  Our current
  47.  * interpretation is the following:
  48.  *
  49.  *      - readimage reads pixels exactly as the device stores them
  50.  *      (converted into DeviceGray or DeviceRGB space if the device
  51.  *      uses a palette).  Pixels with non-unity alpha come out
  52.  *      premultiplied, however the device stores them.
  53.  *
  54.  *      - alphaimage assumes the pixels are premultiplied as appropriate
  55.  *      for the relevant color space.  This makes alphaimage and
  56.  *      readimage complementary, i.e., the output of readimage is
  57.  *      suitable as the input of alphaimage.
  58.  *
  59.  *      - [color]image disregard currentalpha, and treat all input as
  60.  * opaque (alpha = 1).  */
  61. /*
  62.  * Just in case we ever change our minds about the direction of
  63.  * premultiplication, uncommenting the following preprocessor definition is
  64.  * supposed to produce premultiplication towards white.
  65.  */
  66. /*#define PREMULTIPLY_TOWARDS_WHITE */
  67.  
  68. #endif /* gxalpha_INCLUDED */
  69.